package net.wangds.auth.user.repo.rdbms;

import net.wangds.jpa.repository.RemovableRepo;
import net.wangds.auth.user.entity.GeneralUserRoleRef;
import net.wangds.data.DisableEnum;
import net.wangds.data.RemovedEnum;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;

@Repository
public interface UserRoleRefJpaRepo extends RemovableRepo<GeneralUserRoleRef> {

    List<GeneralUserRoleRef> findByUserId(String userId);

    Page<GeneralUserRoleRef> findByUserId(String userId, Pageable page);

    List<GeneralUserRoleRef> findByUserIdAndDisable(String userId, DisableEnum disable);
    List<GeneralUserRoleRef> findByUserIdAndDisableAndRemoved(String userId, DisableEnum disable, RemovedEnum removed);

    Page<GeneralUserRoleRef> findByUserIdAndDisable(String userId, DisableEnum disable, Pageable page);


    Optional<GeneralUserRoleRef> findByUserIdAndRoleId(String userId, String roleId);


    Optional<GeneralUserRoleRef> findByUserIdAndRoleIdAndDisable(String userId, String roleId, DisableEnum disable);

    boolean existsByUserIdAndRoleId(String userId, String roleId);

    boolean existsByUserIdAndRoleIdAndDisable(String userId, String roleId, DisableEnum disable);

    Page<GeneralUserRoleRef> findByUserIdNotInAndDisableAndRemoved(List<String> idlist, DisableEnum normal, RemovedEnum normal1, Pageable pr);
}
